package me.qi.kancha.dto.core;

import com.baomidou.mybatisplus.annotation.*;
import me.qi.kancha.dto.base.BaseDTO;
import me.qi.kancha.dto.enums.AccountStatus;
import me.qi.kancha.dto.enums.AccountType;

import java.io.Serializable;

import com.xhyt.common.resource.support.AccountPrincipal;
import lombok.Data;

/**
 * 
 * @author sun
 * @TableName account
 */
@TableName(value ="account")
@Data
public class AccountDTO extends BaseDTO implements Serializable, AccountPrincipal {

    /**
     * 删除标记
     */
    @TableField(value = "deleted", fill = FieldFill.INSERT)
    @TableLogic(value = "0", delval = "1")
    private Integer deleted;

    /**
     * 状态(1正常，2锁定)
     */
    private AccountStatus status;

    /**
     * 密码
     */
    @TableField(value = "password")
    private String password;

    /**
     * 类型（1密码模式，2小程序jscode(username=appid:openid)）
     */
    private AccountType type;

    /**
     * 用户名
     */
    @TableField(value = "username")
    private String username;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @TableField(exist = false)
    private String unionid;

    @Override
    public boolean isAccountNonLocked() {
        return !AccountStatus.DISABLE.equals(status);
    }

    @Override
    public String getAccountId() {
        return getId();
    }


}